package com.oamicnet;

import com.oamicnet.entity.Student;
import com.oamicnet.service.StudentService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * Hello world!
 */
@ComponentScan("com.oamicnet")
@EnableAspectJAutoProxy
public class App {
    public static void main(String[] args) {
        //1-需要加载xml文件
        /*ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        StudentService studentService = context.getBean("studentService", StudentService.class);
        studentService.save(new Student(1, "zhangsan", "123"));
        studentService.update(new Student(1, "zhangsan", "123"));*/

        //2-不需要xml文件
        ApplicationContext context1 =new AnnotationConfigApplicationContext(App.class);
        StudentService studentService = context1.getBean("studentService",StudentService.class);
        studentService.save(new Student(1, "zhangsan", "123"));
        studentService.update(new Student(1, "zhangsan", "123"));
    }
}
